<?php

/**
 * Description of Sites
 *
 * @author FFOZEU
 */

if( !defined('IN') ) die('Hacking Attempt');


class Sites extends DbFactory{
    //put your code here
    
    protected $nameSites;
    protected $heureOuverture;
    protected $heureFermeture;
    protected $emailServClient;
    protected $emailServTech;
    protected $emailServReclamation;
    protected $emailPaypal;
    protected $devise;
    protected $nameTable = 'c2w_sites';
    
    //GETTERS
    public function getNameSites()
    {
		return $this->nameSites;
	
	}
    
    public function getHeureOuverture()
    {
		return $this->heureOuverture;
	
	}
    
    public function getHeureFermeture()
    {
		return $this->heureFermeture;
	
	}
    
    public function getEmailServClient()
    {
		return $this->emailServClient;
	
	}
    
    public function getEmailServTech()
    {
		return $this->emailServTech;
	
	}
    
    public function getEmailServReclamation()
    {
		return $this->emailServReclamation;
	
	}
    
    //SETTERS
    public function setNameSites($nameSites)
    {
		$this->nameSites = $nameSites;
	
	}
    
    public function setHeureOuverture($heureOuverture)
    {
		$this->heureOuverture = $heureOuverture;
	
	}
    
    public function setHeureFermeture($heureFermeture)
    {
		$this->heureFermeture = $heureFermeture;
	
	}
    
    public function setEmailServClient($emailServClient)
    {
		$this->emailServClient = $emailServClient;
	
	}
    
    public function setEmailServTech($emailServTech)
    {
		$this->emailServTech = $emailServTech;
	
	}
    
    public function setEmailServReclamation($emailServReclamation)
    {
		$this->emailServReclamation = $emailServReclamation;
	
	}
    
    public function setEmailPaypal($emailPaypal)
    {
		$this->emailPaypal = $emailPaypal;
	
	}
    public function setDevise($devise)
    {
		$this->devise = $devise;
	
	}
        public function getSiteName(){
        return isset($_SESSION['site'])?$_SESSION['site']['name']:__SITE__;
    }
    
    public function getEmailSerClient(){
        return isset($_SESSION['site'])?$_SESSION['site']['emailServClient']:__EMAIL__;
    }
    
    public function getEmailSerTech(){
        return isset($_SESSION['site'])?$_SESSION['site']['emailServTech']:__EMAIL__;
    }
    
    public function getEmailSerReclamat(){
        return isset($_SESSION['site'])?$_SESSION['site']['emailServReclamation']:__EMAIL__;
    }
    
    public function getEmailPaypal(){
        return isset($_SESSION['site'])?$_SESSION['site']['emailPaypal']:__EMAIL__;
    }
    
    public function getHourOpen(){
        return isset($_SESSION['site'])?$_SESSION['site']['heureOuverture']:  date('H:i');
    }
    
    public function getHourClose(){
        return isset($_SESSION['site'])?$_SESSION['site']['heureFermeture']:date('H:i');
    }
    
    public function getDevise(){
        return isset($_SESSION['site'])?$_SESSION['site']['devise']:_DEFAULT_DEVISE_;
    }
    public function setSiteInfos(){
		$sites = $this->getSitesInfos();
		if($sites){
			$_SESSION['site']['nameSites'] = $sites['nameSites'];
			$_SESSION['site']['heureOuverture'] = $sites['heureOuverture'];
			$_SESSION['site']['heureFermeture'] = $sites['heureFermeture'];
			$_SESSION['site']['emailServClient'] = $sites['emailServClient'];
			$_SESSION['site']['emailServTech'] = $sites['emailServTech'];
			$_SESSION['site']['emailServReclamation'] = $sites['emailServReclamation'];
			$_SESSION['site']['emailPaypal'] = $sites['emailPaypal'];
            $_SESSION['site']['devise'] = $sites['devise'];
		}
    }
    
    public function getSitesInfos(){
        $sql = " SELECT s.* 
                 FROM ".$this->nameTable." s 
                 LIMIT 1";
        
        $requete = DbFactory::getPdoInstance()->query($sql);
        
        if($data = $requete->fetch(\PDO::FETCH_ASSOC)){
            return $data;
        }
        return null;
    }
}